package mc

import (
	"gitee.com/dreamwood/ez-go/db/mgo"
)

const (
	FlowEventNew          = "mes.FlowNew"
	FlowEventBeforeCreate = "mes.FlowBeforeCreate"
	FlowEventBeforeUpdate = "mes.FlowBeforeUpdate"
	FlowEventBeforeSave   = "mes.FlowBeforeCreate mes.FlowBeforeUpdate"
	FlowEventAfterCreate  = "mes.FlowAfterCreate"
	FlowEventAfterUpdate  = "mes.FlowAfterUpdate"
	FlowEventAfterSave    = "mes.FlowAfterCreate mes.FlowAfterUpdate"
	FlowEventDelete       = "mes.FlowDelete"

	FlowAccessControlEvent = "mes.FlowAccessControl"
)

func GetFlowConfig() *mgo.DocConfig {
	return Flow_Config
}

var Flow_Config *mgo.DocConfig

func init() {
	Flow_Config = NewFlowConfig()
}

func NewFlowConfig() *mgo.DocConfig {
	return &mgo.DocConfig{
		ContainerKey: "mes.Flow",
		Fields: []string{
			"plan", "sn", "template", "papers",
		},
		RelationFields: []string{
			"template", "papers",
		},
		RelationConfigs: map[string]*mgo.DocRelation{

			"template": {
				Config:     GetProcessTemplateConfig,
				DocName:    "ProcessTemplate",
				JoinType:   "O",
				KeyInside:  "templateId",
				KeyOutSide: "id",
			},

			"papers": {
				Config:     GetPaperConfig,
				DocName:    "Paper",
				JoinType:   "M",
				KeyInside:  "id",
				KeyOutSide: "flowId",
			},
		},
		FieldFilter: map[string]*mgo.DocFieldFilter{
			"default": {
				Select: []string{},
				Omit:   []string{},
			},
		},
	}
}
